﻿using System;
using System.ComponentModel;
using System.Windows.Forms;
using Aga.Controls.Tree.NodeControls;
using Aga.Controls.Tree;

namespace MyLibrary.UI
{
    public partial class FolderBrowser : UserControl
    {
        private class ToolTipProvider : IToolTipProvider
        {
            public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl)
            {
                return node.Tag is RootItem ? null : "Second click to rename node";
            }
        }

        public FolderBrowser()
        {
            InitializeComponent();

            _nameText.ToolTipProvider = new ToolTipProvider();
            _nameText.EditorShowing += NameEditorShowing;
            _nameCheck.CheckStateChanged += NameCheckStateChanged;
            treeViewAdv1.Model = new FolderBrowserModel();
            
        }

        private void NameCheckStateChanged(object sender, TreePathEventArgs e)
        {
            MessageBox.Show("state changed");
        }

        private void NameEditorShowing(object sender, CancelEventArgs e)
        {
            if (treeViewAdv1.CurrentNode.Tag is RootItem)
                e.Cancel = true;
        }
    }
}
